package 线程状态;

/**
 * @Author: 李佳芬
 * @Description: 线程停止
 * @DateTime: 2023/3/31 16:20
 **/
public class TestStop implements Runnable{

    private Boolean flag = true;

    @Override
    public void run() {
        int i = 0;
        while (flag){
            System.out.println("我是创建的线程"+"===="+i);
            i++;
        }
    }

    private void Flag(){
        this.flag = false;
    }

    public static void main(String[] args) {

        TestStop testStop = new TestStop();
        new Thread(testStop).start();

        for (int i = 0;i<10000;i++){
            if (i==3000){
              testStop.Flag();
            }
            System.out.println("我是Main线程"+"===="+i);
        }
    }
}
